package org.gdstash.util;

import java.awt.*;

public class GDMsgLogger {
    private static GDLog log;

    public static void clear() {
        GDMsgLogger.log.clear();
    }

    public static void addMessage(final String s, final GDLog.MessageType type) {
        GDMsgLogger.log.addMessage(s, type);
    }

    public static void addMessage(final String s) {
        GDMsgLogger.log.addMessage(s);
    }

    public static void addSuccess(final String s) {
        GDMsgLogger.log.addSuccess(s);
    }

    public static void addInfo(final String s) {
        GDMsgLogger.log.addInfo(s);
    }

    public static void addWarning(final String s) {
        GDMsgLogger.log.addWarning(s);
    }

    public static void addError(final String s) {
        GDMsgLogger.log.addError(s);
    }

    public static void addLowError(final String s) {
        GDMsgLogger.log.addLowError(s);
    }

    public static void addHighError(final String s) {
        GDMsgLogger.log.addHighError(s);
    }

    public static void addWarning(final Throwable ex) {
        GDMsgLogger.log.addWarning(ex);
    }

    public static void addError(final Throwable ex) {
        GDMsgLogger.log.addError(ex);
    }

    public static void addLowError(final Throwable ex) {
        GDMsgLogger.log.addLowError(ex);
    }

    public static void addHighError(final Throwable ex) {
        GDMsgLogger.log.addHighError(ex);
    }

    public static void addLog(final GDLog log) {
        GDMsgLogger.log.addLog(log);
    }

    public static boolean errorsInLog() {
        return GDMsgLogger.log.containsErrors();
    }

    public static boolean severeErrorsInLog() {
        return GDMsgLogger.log.containSevereErrors();
    }

    public static int getNumberLowErrors() {
        return GDMsgLogger.log.getNumberLowErrors();
    }

    public static int getNumberMediumErrors() {
        return GDMsgLogger.log.getNumberMediumErrors();
    }

    public static int getNumberHighErrors() {
        return GDMsgLogger.log.getNumberHighErrors();
    }

    public static void showLog(final Component owner, final String message, final GDLog.MessageType type) {
        GDMsgLogger.log.showLog(owner, message, type);
    }

    public static void showLog(final Component owner, final String error) {
        GDMsgLogger.log.showLog(owner, error);
    }

    public static void showLog(final Component owner, final String success, final GDLog.MessageType type, final String error) {
        GDMsgLogger.log.showLog(owner, success, type, error);
    }

    public static void showLog(final Component owner, final String success, final GDLog.MessageType type, final String error, final boolean showEmpty) {
        GDMsgLogger.log.showLog(owner, success, type, error, showEmpty);
    }

    public static void showLog(final Component owner, final String success, final GDLog.MessageType type, final String error, final boolean showEmpty, final boolean errorOnly) {
        GDMsgLogger.log.showLog(owner, success, type, error, showEmpty, errorOnly);
    }

    public static void showSevereLog(final Component owner, final String success, final GDLog.MessageType type, final String error, final boolean showEmpty, final boolean errorOnly) {
        GDMsgLogger.log.showSevereLog(owner, success, type, error, showEmpty, errorOnly);
    }

    public static void printStackTrace(final Exception ex) {
        final StringBuffer sb = new StringBuffer(500);
        final StackTraceElement[] st = ex.getStackTrace();
        sb.append(ex.getClass().getName() + ": " + ex.getMessage() + "\n");
        for (int i = 0; i < st.length; ++i) {
            sb.append("\t at " + st[i].toString() + "\n");
        }
        System.out.println(sb.toString());
    }

    static {
        GDMsgLogger.log = new GDLog();
    }
}
